package cn.z2huo.demo.hello.kafka.api;

import cn.z2huo.demo.hello.kafka.model.ResultInfo;
import cn.z2huo.demo.hello.kafka.model.ThresholdParam;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.common.TopicPartition;

import java.util.List;

/**
 * <p>
 *
 * @author z2huo
 */
public interface KafkaConsumer extends KafkaConsumable {

    void shutdown();

    /**
     * 消费数据前准备，用来计算应该启动的线程数量
     */
    ThresholdParam beforeConsume(List<ConsumerRecord<String, String>> recordList, TopicPartition topicPartition, int index);

    /**
     * 消费数据
     */
    ResultInfo consume(ThresholdParam thresholdParam);

    /**
     * 是否需要提交 offset
     */
    boolean needSyncOffset();

}
